package com.qwz.sharingjdbc.dao;

import com.qwz.sharingjdbc.pojo.Order;
import io.shardingsphere.transaction.annotation.ShardingTransactionType;
import io.shardingsphere.transaction.api.TransactionType;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.springframework.transaction.annotation.Transactional;

@Mapper
public interface LearnDao {

    //sharding-jdbc的事务注解，必须@ShardingTransactionType和@Transactional一起使用
    //TransactionType.LOCAL - 本地事务 -
    //TransactionType.XA - xa事务 - 适合分表使用
    //@ShardingTransactionType(TransactionType.XA)
    @ShardingTransactionType(TransactionType.LOCAL)
    @Transactional

    @Insert("INSERT INTO t_order (order_id,customer_id,order_time) VALUES(#{orderId},#{customerId},NOW())")
    void add(Order order);
}
